package com.nbsaas.boot.cms.data.entity;

import com.nbsaas.boot.code.annotation.*;
import com.nbsaas.boot.jpa.data.entity.AbstractEntity;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.Table;
import lombok.Data;
import org.hibernate.annotations.Comment;

import java.util.Date;

@CreateByUser
@ComposeView
@Data
@FormAnnotation(title = "文章", model = "文章")
@Entity
@Table(name = "bs_article")
@Comment("文章表")
public class Article extends AbstractEntity {

    @Comment("文章标题")
    @SearchItem(name = "title", key = "title", label = "文章标题")
    @FormField(title = "文章标题", sortNum = "1", grid = true, required = true)
    @Column(length = 200, nullable = false)
    private String title;

    @Comment("文章副标题")
    @FormField(title = "文章副标题", sortNum = "2", grid = true)
    @Column(length = 500)
    private String subtitle;

    @Comment("文章摘要")
    @FormField(title = "文章摘要", sortNum = "3", type = InputType.textarea)
    @Column(length = 1000)
    private String summary;

    @Comment("文章内容")
    @FormField(title = "文章内容", sortNum = "4", type = InputType.richText, col = 23)
    @Column(columnDefinition = "TEXT")
    private String content;

    @Comment("文章分类ID")
    @FormField(title = "文章分类", sortNum = "5", grid = true, type = InputType.select)
    private Long categoryId;

    @Comment("封面图片")
    @FormField(title = "封面图片", sortNum = "6", type = InputType.image)
    @Column(length = 500)
    private String coverImage;

    @Comment("作者")
    @FormField(title = "作者", sortNum = "7", grid = true)
    @Column(length = 100)
    private String author;

    @Comment("文章来源")
    @FormField(title = "文章来源", sortNum = "8", grid = true)
    @Column(length = 200)
    private String source;

    @Comment("文章状态")
    @FormField(title = "文章状态", sortNum = "9", grid = true, type = InputType.select)
    @Column(length = 20)
    private String status; // DRAFT-草稿, PUBLISHED-已发布, ARCHIVED-已归档

    @Comment("发布时间")
    @FormField(title = "发布时间", sortNum = "10", type = InputType.date, grid = true)
    private Date publishTime;

    @Comment("阅读量")
    @FormField(title = "阅读量", sortNum = "11", grid = true, type = InputType.el_input_number, sort = true)
    private Integer readCount;

    @Comment("点赞数")
    @FormField(title = "点赞数", sortNum = "12", grid = true, type = InputType.el_input_number, sort = true)
    private Integer likeCount;

    @Comment("评论数")
    @FormField(title = "评论数", sortNum = "13", grid = true, type = InputType.el_input_number, sort = true)
    private Integer commentCount;

    @Comment("排序")
    @FormField(title = "排序", sortNum = "14", grid = true, type = InputType.el_input_number, sort = true)
    private Integer sort;

    @Comment("是否置顶")
    @FormField(title = "是否置顶", sortNum = "15", grid = true, type = InputType.select)
    private Boolean top;

    @Comment("是否推荐")
    @FormField(title = "是否推荐", sortNum = "16", grid = true, type = InputType.select)
    private Boolean recommended;

    @Comment("是否热门")
    @FormField(title = "是否热门", sortNum = "17", grid = true, type = InputType.select)
    private Boolean hot;

    @Comment("SEO标题")
    @FormField(title = "SEO标题", sortNum = "18")
    @Column(length = 200)
    private String seoTitle;

    @Comment("SEO关键词")
    @FormField(title = "SEO关键词", sortNum = "19")
    @Column(length = 500)
    private String seoKeywords;

    @Comment("SEO描述")
    @FormField(title = "SEO描述", sortNum = "20")
    @Column(length = 1000)
    private String seoDescription;

    @Comment("文章URL别名")
    @FormField(title = "URL别名", sortNum = "21")
    @Column(length = 200, unique = true)
    private String urlAlias;

    @Comment("模板")
    @FormField(title = "模板", sortNum = "22")
    @Column(length = 100)
    private String template;

    @Comment("访问权限")
    @FormField(title = "访问权限", sortNum = "23", grid = true, type = InputType.select)
    @Column(length = 20)
    private String accessLevel; // PUBLIC-公开, PRIVATE-私有, VIP-VIP用户
} 